package org.example.rmsmsapi.controller;
import com.alibaba.fastjson.JSON;
import net.sf.json.JSONArray;
import org.example.rmsmsapi.Utils.JwtUtils;
import org.example.rmsmsapi.Utils.RsaMethod;
import org.example.rmsmsapi.Utils.Sm4Method;
import org.example.rmsmsapi.common.Result;
import org.example.rmsmsapi.dao.testMapper;
import org.example.rmsmsapi.model.*;
import org.example.rmsmsapi.model.Req.*;
import org.example.rmsmsapi.model.Res.*;
import org.example.rmsmsapi.service.UserService;
import org.example.rmsmsapi.service.rmsmsapiservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.*;

@RequestMapping("/api/auth")
@RestController
public class ReqController {

@Resource
    private testMapper mapper;

@Autowired
private rmsmsapiservice service;
@Autowired
private UserService userService;
@Autowired
private JwtUtils jwtUtils;

//@zhoubin start
@Autowired
public Sm4Method Sm4Method;
@Autowired
public RsaMethod RsaMethod;
//@zhoubin end

//@Autowired
//private AuthService authService;
@RequestMapping(value = "test",produces = "application/json")
public String tjhhuyest() {

//    /*测试Sm4*/
//    String ceshi;
//    //System.out.print("7777777周斌");
//    /*Sm4加密数据*/
//    try {
//        ceshi = Sm4Method.Sm4EncryptEcb();
//        System.out.println("加密后返回的测试数据ceshi:" +ceshi);
//    } catch (Exception e) {
//        throw new RuntimeException(e);
//    }
//
//    /*Sm4解密数据*/
//    try {
//        Sm4Method.Sm4DecryptEcb(ceshi);
//    } catch (Exception e) {
//        throw new RuntimeException(e);
//    }
//
//    return String.valueOf(ceshi);

        /*测试RSA*/
      String Rsadate="我用RSA加密解密测试数据";
      try{
          //初始化key
          RsaMethod.InitRsakey();
          /*获取加密数据公钥*/
          PublicKey publicKey= RsaMethod.getpublicKeyValue();
          /*用RSA公钥加密数据*/
          String EncryptRsadate= RsaMethod.encryptByPublicKey(Rsadate,publicKey);
          System.out.println("加密后的数据：" + EncryptRsadate);

          /*用RSA私钥解密数据*/
          PrivateKey privateKey = RsaMethod.getPrivateKeyValue();
          String DecryptRsadata = RsaMethod.decryptByPrivateKey(EncryptRsadate,privateKey);
          System.out.println("解密后的数据：" + DecryptRsadata);
      } catch (Exception e) {
          throw new RuntimeException(e);
      }
    return "测试RSA返回数据";
}
@ResponseBody
@RequestMapping(value = "getHosMap")
/***获取医院键值对用于前端查询**/
public Result<Map<String, Object>>getHosMap() {
    Map<String, Object> result = new HashMap<>();
    result.put("status", "success");
    result.put("data", service.getHosMap());
    return Result.success(result);
}

//@zhoubin TRACE(高) ← DEBUG ← INFO ← WARN ← ERROR(低)

@ResponseBody
/**获取东华医保报销信息**/
@RequestMapping(value = "GetYbpaInfo")
public Result<Map<String, Object>> GetInPameasure(@RequestBody GetYbReq req){
    Map<String, Object> result = new HashMap<>();

    if(service.validateRmsperson(req.getSfzh())){
        List<ybbxInfo> list=new ArrayList<>();
        list=service.assembleYbinfo(service.GetybbxInfo(req.getSfzh()));
        if (list==null || list.size()==0){
            result.put("status", "未查询到该人员住院医保信息，请检查！");
            return    Result.success(result);
        }
        if (list.size()>0){
            result.put("status","success");
            result.put("data",list);
            return Result.success(result);
        }
        else {
            result.put("status", "未查询到该人员住院医保信息，请检查！");
            return Result.success(result);
        }
    }
    else {
        result.put("status", "该人员未在平台里面查询到享受优抚政策，请检查是否身份证信息录入错误或联系相关部门是否人员信息未更新！");
        return Result.success(result);
    }

}





    /***
     * 登录没有使用
     * @param req
     */
    @ResponseBody
    @RequestMapping(value = "login",produces = "application/json",method = RequestMethod.POST)
    public String login(@RequestBody loginReq req) {
   if(req!=null){
   return  service.Login(req.getUserCode(),req.getPassWord());
 }
   else {
       ResInfo res=new ResInfo();
       res.setResultCode("0");
       res.setResultMsg("用户名和密码不符合，请检查！");
       return JSON.toJSONString(res);
   }
}
/**用户登录并获取token **/
@ResponseBody()
@PostMapping(value = "mlogin",produces = "application/json")
  public Result<Map<String, Object>> mlogin(@RequestBody loginReq req){
        // 验证用户名和密码
        uRoles user = userService.validateUser(req.getUserCode(),req.getPassWord());
        if (user == null) {
            return Result.error("用户名或密码错误");
        }

        // 生成Token
        String token = jwtUtils.generateToken(user.getUserId(),JSON.toJSONString(user.getRoles()));

        // 返回结果
        Map<String, Object> result = new HashMap<>();
        result.put("user", user);
        result.put("token", token);
        return Result.success(result);
    }
/**二次登陆不知道有什么鬼用**/
    @ResponseBody
    @RequestMapping(value = "nainfo",produces = "application/json",method = RequestMethod.POST)
    public String nalogin(@RequestBody loginReq req) {
        if(req!=null){
            return  service.Login(req.getUserCode(),req.getPassWord());
        }
        else {
            ResInfo res=new ResInfo();
            res.setResultCode("0");
            res.setResultMsg("用户名和密码不符合，请检查！");
            return JSON.toJSONString(res);
        }
    }

    /**获取退役军人信息**/
    @ResponseBody
    @RequestMapping(value = "GetRmsinfo",produces ="application/json",method = RequestMethod.POST)
    public Result<Map<String, Object>>  GetRmsinfo(@RequestBody rmspeson req) {
       // ResInfo res=new ResInfo();
        // 返回结果
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
            result.put("data", service.Getrmspeson(req));
            result.put("rmstype",service.GetrmsType());
          //  result.put("token", token);
            return Result.success(result);
//            res.setResultCode("0");
//            res.setResultMsg("success");
//            res.setData(JSON.toJSONString(service.Getrmspeson(req)));
//            return JSON.toJSONString(res);
        }
        else {
            return Result.error("请求参数为空，请检查！");
        }
    }

    /**修改tyjr信息**/
    @ResponseBody()
    @RequestMapping(value = "UpRmsinfo",produces ="application/json",method = RequestMethod.POST)
    public Result<Map<String, Object>>  UpRmsinfo(@RequestBody rmspeson req) {
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
            service.Updatermspeson(req);
            result.put("data", service.Getrmspeson(req));
            result.put("rmstype",service.GetrmsType());
            //  result.put("token", token);
            return Result.success(result);
//            res.setResultCode("0");
//            res.setResultMsg("success");
//            res.setData(JSON.toJSONString(service.Getrmspeson(req)));
//            return JSON.toJSONString(res);
        }
        else {
            return Result.error("请求参数为空，请检查！");
        }
    }
    /**新增退役军人信息**/
    @ResponseBody()
    @RequestMapping(value = "addRmsinfo",produces ="application/json",method = RequestMethod.POST)
    public Result<Map<String, Object>> addRmsinfo(@RequestBody rmspeson req) {
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
            service.Insertmspeson(req);
            result.put("data", service.Getrmspeson(req));
            result.put("rmstype",service.GetrmsType());
            //  result.put("token", token);
            return Result.success(result);
        }
        else {
            return Result.error("请求参数为空，请检查！");
        }
    }
/***获取退役军人结算明细信息按时间**/
    @ResponseBody()
    @RequestMapping(value = "getrmscosDetail",method =RequestMethod.POST,produces ="application/json" )
    public Result<Map<String, Object>> GetrmscostDetail(@RequestBody insuinfobydateReq req) {
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
           result.put("data",service.GetInsucostDetail(req));
            return Result.success(result);
        }
        else {
            return Result.error("请求参数为空，请检查！");
        }
    }
    //通过类型、对账单号、时间、用户名等获取明细结算信息
    @ResponseBody
    @RequestMapping(value = "Getdzmxinfobytp",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>Getdzmxinfobytp(@RequestBody dzddetailreq req) {
        Map<String, Object> result = new HashMap<>();
        List<insudoReq>  res=new ArrayList<>();
        res=service.Getdztpinsudetail(req);
        if(req==null){
           result.put("status","请求参数为空，请检查!");
           return Result.success(result);
        }
        else {
            if(res==null || res.size()==0){
                result.put("status","系统未查询到相应明细，请联系管理员！");
                return Result.success(result);
            }
            result.put("status","success");
            result.put("data",res);
            return Result.success(result);
        }

    }
    /***获取清算明细**/
    @ResponseBody
    @RequestMapping(value = "getqsmxinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>getqsmxinfo(@RequestBody qsdataReq req){
        System.out.print("-----》》》》》"+JSON.toJSONString(req));
        Map<String, Object> result = new HashMap<>();
        if(req==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        List<qsdetailRes> resList=new ArrayList<>();
        resList=service.getQsdetail(req);
        if(resList==null || resList.size()==0){
            result.put("status","根据请求参数没有查询到任何记录，请检查");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",resList);
        return Result.success(result);
    }

/**获取银行卡信息***/
    @ResponseBody
    @RequestMapping(value ="getBankInfo",method = RequestMethod.POST,produces ="application/json" )
    public Result<Map<String, Object>> getbankInfo(@RequestBody bankInfo b){
        Map<String, Object> result = new HashMap<>();
        if(b==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        else {
            List<bankInfo> resList=new ArrayList<>();
            resList=service.GetBankInfo(b);
            if(resList==null || resList.size()==0){
                result.put("status","该人员未在维护名单中，请与退役军人管理中心联系");
                return Result.success(result);
            }
            result.put("status","success");
            result.put("data",resList);
        }
        return Result.success(result);
    }
//    编辑银行卡信息
   @ResponseBody
   @RequestMapping(value ="editBankInfo",method = RequestMethod.POST,produces ="application/json")
   public Result<Map<String, Object>> editbankInfo(@RequestBody bankInfo b){
       Map<String, Object> result = new HashMap<>();
       if(b==null){
           result.put("status","请求参数为空，请检查！");
           return Result.success(result);
       }
       else {
           List<bankInfo> resList=new ArrayList<>();
           resList=service.EditerBankInfo(b);
           if(resList==null || resList.size()==0){
               result.put("status","该人员未在维护名单中，请与退役军人管理中心联系");
               return Result.success(result);
           }
           result.put("status","success");
           result.put("data",resList);
       }
       return Result.success(result);
   }
    /****
     * 获取医院信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "getHosinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>getHosinfo(@RequestBody hosinfo r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.Gethosinfo(r));
        return Result.success(result);
    }

    /****
     * 获取角色信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "getroleinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>getroleinfo(@RequestBody roleModel  r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.Getroleinfo(r));
        return Result.success(result);
    }

    /****
     * 获取人员类型信息
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "getpersonTypeinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>getpersonTypeinfo(@RequestBody personTypeModel h){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.GetpersonTypenfo(h));
        return Result.success(result);
    }
    /****
     * 获取用户信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "getuserinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>>getuserinfo(@RequestBody userinfoModel r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.Getuserinfo(r));
        return Result.success(result);
    }

    /****
     * 更新医院信息
     * @param r
     * @return
     */
    @ResponseBody
@RequestMapping(value = "updatehosinfo",method = RequestMethod.POST,produces ="application/json")
public Result<Map<String, Object>> updatehosinfo(@RequestBody hosinfo r){
        Map<String, Object> result = new HashMap<>();
     result.put("status","success");
     result.put("data",service.Uphosinfo(r));
     return Result.success(result);
}

    /****
     * 更新角色信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "updateroleinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> updateroleinfo(@RequestBody roleModel r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.Uproleinfo(r));
        return Result.success(result);
    }

    /****
     * 更新人员类型信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "updateperTypeinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> updateperTypeinfo(@RequestBody personTypeModel h){
        System.out.print("请求参数："+JSON.toJSONString(h));
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.UpperonTypeinfo(h));
        return Result.success(result);
    }

    /****
     * 更新用户信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "updateuserinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> updateuserinfo(@RequestBody userinfoModel r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.Upuserinfo(r));
        return Result.success(result);
    }
    /****
     * 保存医院信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "savehosinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> savehosinfo(@RequestBody hosinfo r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.saveHosinfo(r));
        return Result.success(result);
    }
    /****
     * 保存用户类型信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "savepersionTypeinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> savepersionTypeinfo(@RequestBody personTypeModel h){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.savepersonTypeinfo(h));
        return Result.success(result);
    }

    /****
     * 保存用户信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "saveuserinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> saveuserinfo(@RequestBody userinfoModel r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.saveUserinfo(r));
        return Result.success(result);
    }

    /****
     * 保存角色信息
     * @param r
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "saveroleinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> saveroleinfo(@RequestBody roleModel  r){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.saveroleinfo(r));
        return Result.success(result);
    }


    /***获取用户匹配信息 ***/
    @ResponseBody
    @RequestMapping(value = "GetuserMatchinfo")
    public Result<Map<String, Object>> getuserMatchinfo(){
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        result.put("data",service.GetuserMatchModel());
        return Result.success(result);
    }

/***获取未清算数据用于清算生成数据***/
    @ResponseBody
    @RequestMapping(value = "Gethosqsinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> Gethosqsinfo(@RequestBody  liquiReq r){
        Map<String, Object> result = new HashMap<>();
        if(r==null){
        result.put("status","请求参数为空！,请检查");
        return Result.success(result);
        }
        qsdRes res=new qsdRes();
        res=service.Gethosqsinfo(r);
        if(res==null){
            result.put("status","未查询到需要清算的数据");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }

    /**保存清算表**/
    @ResponseBody
    @RequestMapping(value = "saveqsb",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> saveqsb(@RequestBody  qsdRes r){
        Map<String, Object> result = new HashMap<>();
  if(r==null){
  result.put("status","请求参数为空，请检查!");
  return Result.success(result);
  }
        qsdRes res=new qsdRes();
        res=service.saveqsinfo(r);
        if(res==null){
            result.put("status","保存失败");
        }
        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }

   /**获取清算表数据***/
    @ResponseBody
    @RequestMapping(value = "Getcliinque",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> Getcliinque(@RequestBody qsdRes r){
        //System.out.print("ppppp"+JSON.toJSONString(r));
        Map<String, Object> result = new HashMap<>();
        if(r==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        List<qsdRes> list=new ArrayList<>();
        list=service.Getqsinfo(r);
        if(list==null || list.size()==0){
            result.put("status","根据入参没有查询到相应数据，如有疑问请联系管理员！");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",list);
        return Result.success(result);

    }


    /**获取清算表数据用于审核和作废及后续查询***/
    @ResponseBody
    @RequestMapping(value = "Getcliinquem",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> Getcliinquem(@RequestBody qsdRes r){
        //System.out.print("ppppp"+JSON.toJSONString(r));
        Map<String, Object> result = new HashMap<>();
        if(r==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        List<qsdRes> list=new ArrayList<>();
        list=service.Getqsinfo1(r);
        if(list==null || list.size()==0){
            result.put("status","根据入参没有查询到相应数据，如有疑问请联系管理员！");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",list);
        return Result.success(result);

    }
/****更新清算数据用于作废和审核**/
    @ResponseBody
    @RequestMapping(value ="upqsinfo",method = RequestMethod.POST,produces ="application/json" )
    public Result<Map<String, Object>> upqsinfo(@RequestBody  qsdRes r){
        Map<String, Object> result = new HashMap<>();
        if(r==null){
            result.put("status","请求参数为空，请检查");
            return Result.success(result);
        }
        if (r.getQsid()==null){
             result.put("status","清算编号为空，请检查!");
             return Result.success(result);
        }
        qsdRes res=new qsdRes();
        res=service.upQsinfo(r);
        if(res==null){
            result.put("status","未获取到相应数据，请检查!");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }
    /*****
     * 作废对账单
     * @param req
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "canclehosdz",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String,Object>> canclehosdz(@RequestBody dzdinfo req){
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
            if(req.getDzdh()==null){
                result.put("status","对账单号为空，请求参数不规范，请检查!");
                return Result.success(result);
            }
            result.put("status",service.canclehosdzd(req));
            return Result.success(result);
        }
        else {
            result.put("status","请求参数为空请检查!");
            return Result.success(result);
        }
    }
    /***获取对账信息**/
    @ResponseBody
    @RequestMapping(value = "Getyndzinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String,Object>>getyndzgr( @RequestBody  dzdinfo req){
        System.out.print("iiiiii"+JSON.toJSONString(req));
        Map<String, Object> result = new HashMap<>();
        if(req!=null){
            List<dzdinfo>list=new ArrayList<>();
            list=service.GetdzinfoBytime(req);

            if(list==null || list.size()==0){
                result.put("status","未查询到相关对账信息，请检查！");
                return Result.success(result);
            }
            result.put("status","success");
            result.put("data",list);
            return Result.success(result);
        }
        else {
            result.put("status","请求参数为空请检查!");
                return Result.success(result);
        }
    }

    /***获取未对账信息，用于查询未对账***/
    @ResponseBody
    @RequestMapping(value = "Getnorencinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String,Object>>getnorencinfo(@RequestBody norencque r){
        Map<String, Object> result = new HashMap<>();
        if(r!=null){
            if(r.getHosid()!=null){

                List<norencque> list=new ArrayList<>();
                list=service.GetnoRencinfo(r);
                if(list==null || list.size()==0){
                    result.put("status","没有未对账信息");
                    return Result.success(result);
                }
                else {
                    result.put("status","success");
                    result.put("data",list);
                    return Result.success(result);
                }

            }
            else {
                result.put("status","医院ID参数为空，请检查");
                return Result.success(result);
            }

        }
        else {
            return  Result.error("请求参数为空！");
        }
    }
    /**获取ty军人类型*/
    @ResponseBody
    @RequestMapping(value = "GetRmstype")
    public Result<Map<String, Object>> getrmsType() {
        Map<String, Object> result = new HashMap<>();
        result.put("data", service.GetrmsType());
        return Result.success(result);
    }
/***进行二次报销*/
    @ResponseBody
    @RequestMapping(value ="insudoinfo")
    public Result<Map<String, Object>> insudoinfo(@RequestBody insudoReq req) {
        Map<String, Object> result = new HashMap<>();
        if(req==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        else {
            List<insudoReq> insudoList=new ArrayList<>();
            insudoList=service.insudoInfo(req);
            if(insudoList==null || insudoList.size()==0){
              result.put("status","该人员已经进行二次报销，请检查核实！");
                return Result.success(result);
            }
            else {
                result.put("status","success");
                result.put("data",insudoList);
                return Result.success(result);
            }

        }

    }

    /***修改报销数据*/
    @ResponseBody
    @RequestMapping(value ="upinsudoinfo",produces ="application/json",method = RequestMethod.POST)
    public Result<Map<String, Object>> Upsudoinfo(@RequestBody insudoReq req) {
        Map<String, Object> result = new HashMap<>();
        if (req == null) {
            result.put("status", "请求参数为空，请检查！");
            return Result.success(result);
        } else {
            List<insudoReq> insudoList = new ArrayList<>();
            insudoList = service.UpInsucostDetail(req);
            if (insudoList == null || insudoList.size() == 0) {
                result.put("status", "未查询到报销信息，请检查核实！");
                return Result.success(result);
            } else {
                result.put("status", "success");
                result.put("data", insudoList);
                return Result.success(result);
            }

        }
    }


    /*****
     * 获取退役军人二次报销信息
     * @param req
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "GethosSecInfo",produces ="application/json",method = RequestMethod.POST)
    public Result<Map<String, Object>> getSecInsuinfo(@RequestBody insudoReq req){
        Map<String, Object> result = new HashMap<>();
        if(req==null){
            result.put("status","请求参数为空，请检查！");
            return Result.success(result);
        }
        else {
            List<insudoReq> list=new ArrayList<>();
            list=service.GetinsuSec(req);
            if(list==null ||list.size()==0){
                result.put("status","该人员没有历史退役报销信息，请检查");
                return Result.success(result);
            }
            else {
                result.put("status","success");
                result.put("data",list);
                return Result.success(result);
            }
        }
    }

    /**获取对账数据用于生成对账表单**/
    @ResponseBody
    @RequestMapping(value = "Getdzinfo",method = RequestMethod.POST,produces ="application/json")
    public Result<Map<String, Object>> Getdzinfo(@RequestBody dzdinfo r) {
        Map<String, Object> result = new HashMap<>();
        dzinfoRes res=new dzinfoRes();
        if(r==null){
            result.put("status","请求为空请检查");
            return Result.success(result);
        }
        if(r.getUserCode()==null){
            result.put("status","请求用户代码为空请检查");
            return Result.success(result);
        }
        res=service.Getreconlist(r);
        if(res==null){
            result.put("status","没有需要进行对账数据请检查！");
            return Result.success(result);
        }

        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }
    /**查询对账信息已对账的，生成可用于打印的对账单**/
    @ResponseBody
    @RequestMapping(value = "getdzque",method = RequestMethod.POST,produces ="application/json")
    public  Result<Map<String, Object>> getdzque(@RequestBody dzdinfo r) {
        Map<String, Object> result = new HashMap<>();
        dzinfoRes res=new dzinfoRes();
        if(r==null){
            result.put("status","请求为空请检查");
            return Result.success(result);
        }
        if(r.getUserCode()==null){
            result.put("status","请求用户代码为空请检查");
            return Result.success(result);
        }
        res=service.GetdzdBYque(r);
        if(res==null){
            result.put("status","没有需要进行对账数据请检查！");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }
    /**生成对账单保存并更新明细**/
    @ResponseBody
    @RequestMapping(value = "GenerentRMSdetail",method = RequestMethod.POST,produces = "application/json")
    public Result<Map<String, Object>> GenremtRms(@RequestBody dzdinfo r){
        Map<String, Object> result = new HashMap<>();
        if(r==null){
            result.put("status","请求为空请检查");
            return Result.success(result);
        }
        if(r.getUserCode()==null){
            result.put("status","请求用户代码为空请检查");
            return Result.success(result);
        }
        result.put("status","success");
        result.put("data",service.genaretdzd(r));
        return Result.success(result);
    }

    /***获取角色对应权限**/
    @ResponseBody
    @RequestMapping(value = "GetRspinfo")
    public Result<Map<String, Object>> getRspinfo() {
        Map<String, Object> result = new HashMap<>();
        result.put("status","success");
        rcpRes res=new rcpRes();
        res=service.Getrcpinfo();
        result.put("data",res);
        return Result.success(result);
    }
    /***添加角色对应权限信息**/
    @ResponseBody
    @RequestMapping(value = "upCrossPermission",method = RequestMethod.POST,produces = "application/json")
    public Result<Map<String, Object>> upCrossPermission(@RequestBody CorsReq r) {
        Map<String, Object> result = new HashMap<>();
        System.out.print("----"+r.getDatas());
        JSONArray jsonArray=JSONArray.fromObject(r.getDatas());
        List<RcpModel> ms=new ArrayList<>();
        ms= JSONArray.toList(jsonArray,RcpModel.class);
        if(ms==null || ms.size()==0){
            result.put("status","请求为空请检查");
            return Result.success(result);
        }
        rcpRes res=new rcpRes();
        res=service.UpCrosinfo(ms);
        result.put("status","success");
        result.put("data",res);
        return Result.success(result);
    }
}
